package action;

import lombok.Data;
import org.apache.struts2.ServletActionContext;
import org.springframework.beans.factory.annotation.Autowired;
import pojo.Schedule;
import service.ScheduleService;
import util.GsonUtil;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
@Data
public class ScheduleAction {
    @Autowired
    private ScheduleService scheduleService;
    private Schedule schedule;
    public void queryByDate() throws Exception {
        List<Schedule> schedules = scheduleService.queryByDate();
        HttpServletResponse response = ServletActionContext.getResponse();
        response.setCharacterEncoding("UTF-8");
        PrintWriter out = response.getWriter();
        out.print(GsonUtil.toJson(schedules));
    }
    public void queryByRoom() throws Exception {
        List<Schedule> schedules = scheduleService.queryByRoom(schedule);
        HttpServletResponse response = ServletActionContext.getResponse();
        response.setCharacterEncoding("UTF-8");
        PrintWriter out = response.getWriter();
        out.print(GsonUtil.toJson(schedules));
    }
}
